﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.Entities;
using MAF.CRUD;
using Domain;
using MAF.Common;
using Database;
using Database.Persistence;
using System.Collections.Specialized;

namespace Business
{
    public class ArticleSvc : BusinessCRUD<Content>,ICRUD<Content>
    {
        #region 构造方法

        public ArticleSvc(string module) : base(DBFactory.GetInstance(module).CreateArticle()) { }
        
        #endregion

        #region 覆盖公共方法

        public override void Add(Content info)
        {
            if (Guid.Empty == info.ParentId)
                throw new Exception("所属分类不能为空");

            if (DateTime.MinValue == info.PublishedDate)
                info.PublishedDate = DateTime.Now;

            base.Add(info);
        }

        public override void Update(Content info)
        {            
            if (Guid.Empty == info.ParentId)
                throw new Exception("所属分类不能为空");

            if (DateTime.MinValue == info.PublishedDate)
                info.PublishedDate = DateTime.Now;

            base.Update(info);
        }

        #endregion
    }
}
